# -*- coding: utf-8 -*-
# 摘要算法简介
# Python的hashlib提供了常见的摘要算法，如MD5,SHA1等

import hashlib

md5 = hashlib.md5()
# md5.update('how to use md5 in python hashlib?'.encode('utf-8'))
# print(md5.hexdigest())

# 分块多次调用update 也可以
md5.update('how to use md5 in '.encode('utf-8'))
md5.update('python hashlib?'.encode('utf-8'))
print(md5.hexdigest())

# SHA1
shal = hashlib.sha1()
shal.update('how to use shal in '.encode('utf-8'))
shal.update('python hashlib?'.encode('utf-8'))
print(shal.hexdigest())